import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import Icons from "unplugin-icons/vite";
import { prismjsPlugin as prismjs } from "vite-plugin-prismjs";
import IconsResolver from "unplugin-icons/resolver";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver(), IconsResolver()],
      imports: ["vue", "vue-router", "vuex"], // 自动导入vue和vue-router相关函数
      dts: "auto-import.d.ts", // 生成 `auto-import.d.ts` 全局声明
    }),
    Components({
      resolvers: [ElementPlusResolver(), IconsResolver({ prefix: "icon" })],
    }),
    Icons({
      autoInstall: true,
    }),
    prismjs({
      languages: "all",
      plugins: [
        "line-numbers",
        "show-language",
        "autolinker",
        "copy-to-clipboard",
      ],
      theme: "tomorrow",
      css: true,
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
});
